package com.masterclient.app.businessmodule.minemodule.redpack.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.masterclient.app.R;
import com.masterclient.app.modules.coupon.beans.RedPackedDetailsBean;
import com.eoner.baselibrary.utils.ScreenUtils;
import com.eoner.baselibrary.utils.ViewTransformUtil;

import jp.wasabeef.glide.transformations.RoundedCornersTransformation;

/**
 * @auther hjian
 * @date 2020/1/2.
 */
public class RewardBillingAdapter extends BaseQuickAdapter<RedPackedDetailsBean.ShTaskProductBean, BaseViewHolder> {
    private int type;
    public RewardBillingAdapter(int type) {
        super(R.layout.item_reward_billing);
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, RedPackedDetailsBean.ShTaskProductBean item) {
        ViewTransformUtil.glideImageView(mContext,item.getSh_image(),(ImageView) helper.getView(R.id.item_billing_img),
                new RoundedCornersTransformation(ScreenUtils.dp2px(4), 0),
                R.mipmap.defaults,ScreenUtils.dp2px(107), ScreenUtils.dp2px(107));
        helper.setText(R.id.item_billing_title, item.getSh_name())
                .setGone(R.id.item_billing_line, helper.getAdapterPosition() != getData().size()-1);
        LinearLayout ll = helper.getView(R.id.item_billing_ll);
        ll.removeAllViews();
        for (RedPackedDetailsBean.ShDetailBean  shDetailBean : item.getSh_detail()) {
            View view = View.inflate(mContext, R.layout.item_red_packed_text, null);
            ((TextView)view.findViewById(R.id.item_text_left)).setText(shDetailBean.getSh_key());
            ((TextView)view.findViewById(R.id.item_text_right)).setText((type == 6?"x":"¥")+shDetailBean.getSh_value());
            ll.addView(view);
        }
    }
}
